﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace eShop.DataAccess.Converter
{
    public class UserProfileConverter
    {
        public static List<Model.UserProfile> ConvertToModelObject(List<Entity.UserProfile> entities)
        {
            List<Model.UserProfile> models = new List<Model.UserProfile>(entities.Count);
            foreach (Entity.UserProfile entity in entities)
            {
                models.Add(ConvertToModelObject(entity));
            }
            return models;
        }

        public static Model.UserProfile ConvertToModelObject(Entity.UserProfile entity)
        {
            if (entity == null) return null;
            Model.UserProfile model = new Model.UserProfile();
            model.Id = entity.Id;
            model.UserId = entity.UserId;

            model.FirstName = entity.FirstName;
            model.LastName = entity.LastName;
            model.EmailAddress = entity.EmailAddress;
            model.DateOfBirth = entity.DateOfBirth;
            model.Gender = entity.Gender;
            model.PhoneNumber = entity.PhoneNumber;

            return model;
        }

        public static Entity.UserProfile ConvertToEntity(Model.UserProfile model)
        {
            Entity.UserProfile entity = new Entity.UserProfile();
            entity.Id = model.Id;
            entity.UserId = model.UserId;
            entity.FirstName = model.FirstName;
            entity.LastName = model.LastName;
            entity.EmailAddress = model.EmailAddress;
            entity.DateOfBirth = model.DateOfBirth;
            entity.Gender = model.Gender;
            entity.PhoneNumber = model.PhoneNumber;
            return entity;
        }

    }
}
